import Layout from '@/layout'
import RouteButtonsBuilder from '@/framework/infra/router/RouterButtonsBuilder'

function buildOrderRouter(name, title, status) {
  return {
    path: name,
    name: name,
    component: () => import('@/feature/oms/app/order/index'),
    meta: {title, icon: 'el-icon-s-order', status},
    buttons: RouteButtonsBuilder.builder(name).r()
      .build()
  }
}

export default [
  {
    path: '/oms',
    component: Layout,
    name: 'oms',
    meta: {title: '发货管理', icon: 'el-icon-s-order'},
    children: [
      // {
      //   path: 'all-order',
      //   name: 'all-order',
      //   component: () => import('@/feature/oms/app/order/index'),
      //   meta: { title: '全部订单', icon: 'el-icon-s-order' },
      //   buttons: RouteButtonsBuilder.builder('all-order').r().addButton({
      //     name: 'orderDetail',
      //     label: '订单详情',
      //     icon: 'el-icon-view'
      //   })
      //     .build()
      // },
      // ...OrderStatusEnum.getValues().map(el => buildOrderRouter('oms-order-' + el.id, el.name, el.id))
      // {
      //   path: 'order-comment',
      //   name: 'order-comment',
      //   component: () => import('@/feature/oms/app/order/comment'),
      //   meta: { title: '订单评论', icon: 'el-icon-s-order' },
      //   buttons: RouteButtonsBuilder.builder('order-comment').r()
      //     .build()
      // },
      {
        path: 'order',
        name: 'oms-order',
        component: () => import('@/feature/oms/app/order/index'),
        meta: {title: '订单查询', icon: 'table'},
        buttons: RouteButtonsBuilder.builder('oms-order').r()
          .build()
      },
      {
        path: 'freight-template/index',
        name: 'pdt-freight-template',
        component: () => import('@/feature/pdt/app/freight-template/index'),
        meta: {title: '物流工具', icon: 'table'},
        buttons: RouteButtonsBuilder.builder('pdt-freight-template').setTitle('退货地址').curdNoBatch({exported: false, hasRefresh: false})
          .addButton({
            name: 'setAsDefault',
            label: '设为默认',
            showFilter: row => row.defaultFlag === 0
          }).build()
      },
      {
        path: 'freight-template/add',
        name: 'freight-template:add',
        hidden: true,
        component: () => import('@/feature/pdt/app/freight-template/add'),
        meta: {title: '新建运费模板', icon: 'table'}
      },
      {
        path: 'freight-template/edit',
        name: 'freight-template:edit',
        hidden: true,
        component: () => import('@/feature/pdt/app/freight-template/edit'),
        meta: {title: '修改运费模板', icon: 'table'}
      }
      // ...OrderStatusEnum.getValues().map(el => buildOrderRouter('oms-order-' + el.id, el.name, el.id)),
      // {
      //   path: 'after-sale-apply',
      //   name: 'oms-after-sale-apply',
      //   component: () => import('@/feature/oms/app/after-sale-apply/index'),
      //   meta: {title: '售后服务', icon: 'table'},
      //   buttons: RouteButtonsBuilder.builder('oms-after-sale-apply').curdoo()
      //     .build()
      // },
      // {
      //   path: 'after-sale-reason',
      //   name: 'oms-after-sale-reason',
      //   component: () => import('@/feature/oms/app/after-sale-reason/index'),
      //   meta: { title: '申请原因', icon: 'table' },
      //   buttons: RouteButtonsBuilder.builder('oms-after-sale-reason').curd()
      //     .build()
      // },
      // {
      //   path: 'amount-refund-apply',
      //   name: 'oms-amount-refund-apply',
      //   component: () => import('@/feature/oms/app/amount-refund-apply/index'),
      //   meta: {title: '退款申请', icon: 'table'},
      //   buttons: RouteButtonsBuilder.builder('oms-amount-refund-apply').curdoo()
      //     .build()
      // }
      // #appendSpot# 生成工具用，不要删了
    ]
  }
]
